﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PSDLib.Models;
using PSDLib;

namespace PSDManager
{
    public partial class BurnJobInfo : UserControl
    {
        private int state = (int)BurnDVDState.等待刻录;

        public int State
        {
            get { return state; }
            set
            {
                state = value;
                progressBar1.Visible = false;
                if (state == (int)BurnDVDState.等待刻录)
                {
                    pictureBox1.Image = Properties.Resources.burn_6;
                }
                else if (state == (int)BurnDVDState.正在刻录)
                {
                    pictureBox1.Image = Properties.Resources.burning;
                    progressBar1.Visible = true;
                }
                else if (state == (int)BurnDVDState.刻录完成)
                {
                    pictureBox1.Image = Properties.Resources.burn_success;
                }
                else if (state == (int)BurnDVDState.刻录失败)
                {
                    pictureBox1.Image = Properties.Resources.burn_failed;
                }
                else if (state == (int)BurnDVDState.刻录取消)
                {
                    pictureBox1.Image = Properties.Resources.burn_cancel;
                }
                else
                {
                    pictureBox1.Image = Properties.Resources.burn_6;
                }
            }
        }

        private BurnJob burnJob;

        public BurnJobInfo()
        {
            InitializeComponent();
            this.progressBar1.Minimum = 0;
            this.progressBar1.Maximum = 100;
        }

        public void SetBurnJob(BurnJob job)
        {
            burnJob = job;

            this.lblTitle.Text = job.DVD.dvd_title + "[" + job.DVD.file_count + "个文件，" + PSDFunction.FormatByteSize(job.DVD.file_total_size) + "]";
            //if (job.State != (int)ResultCode.su)
            this.progressBar1.Value = job.DVD.burn_percent;
            this.state = job.DVD.state;
        }
    }
}
